from django.urls import path, re_path,include
from django.views.generic import RedirectView
from myapp import views
app_name = 'myapp' #设置命名空间
urlpatterns = [
    path('', views.myapp, name='myapp'),  # 根 URL 的路由
    path('hello/', views.hello,name='hello_Django'),  # 不带参数的路由
    path('add/<int:num1>/<int:num2>/', views.add_numbers,name='add'),  # 带参数的路由
    re_path(r'^post-(\d+)/$', views.post_number,name='post_number'),  # 使用正则表达式的路由
    path('dynamic-url/', views.dynamic_url, name='dynamic_url'),  # 动态 URL 视图
    path('home/', RedirectView.as_view(url='/hello/'), name='home'),  # 重定向到首页
    path('redirect/', views.redirect_to_add, name='redirect_to_add'),  # 重定向到 'add' 视图
]


